import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getPaperListAPI } from '@/api/paper'

export const usePaperStore = defineStore('paper', () => {
  const paperList = ref([])
  const paperTotal = ref(0)

  const getPaperList = async (
    val = {
      id: localStorage.getItem('uid'),
      subjectId: '',
      paperType: '',
      keyword: '',
      pageSize: 15,
      pageIndex: 1
    }
  ) => {
    const { data: res } = await getPaperListAPI(val)
    if (res.status === 200) {
      paperList.value = res.data
      paperTotal.value = res.total
    }
  }

  return {
    paperList,
    getPaperList,
    paperTotal
  }
})
